import org.rsbot.script.methods.Calculations;
import org.rsbot.script.methods.Walking;
import org.rsbot.script.wrappers.RSArea;
import org.rsbot.script.wrappers.RSPlayer;
import org.rsbot.script.wrappers.RSTile;

abstract class GuildRanger$WalkToArea extends GuildRanger.Action
{
  private final RSArea destination;
  private final String description;
  private RSTile location;

  public GuildRanger$WalkToArea(GuildRanger paramGuildRanger, RSArea paramRSArea, String paramString)
  {
    super(paramGuildRanger, null);
    this.destination = paramRSArea;
    this.description = paramString;
  }

  public abstract boolean isTargetValid();

  public void execute() {
    if ((!GuildRanger.access$1100(this.this$0).isRunEnabled()) && (GuildRanger.access$1200(this.this$0).getEnergy() > this.this$0.random(20, 50))) {
      GuildRanger.access$1300(this.this$0).setRun(true);
      this.this$0.sleep(500);
    }
    RSTile localRSTile = this.destination.getCentralTile();
    if ((this.location != null) && (!this.this$0.getMyPlayer().isIdle())) { if (GuildRanger.access$1400(this.this$0).distanceTo(this.location) < 10) if (this.destination.contains(new RSTile[] { this.location })); 
    }
    else
    {
      if ((GuildRanger.access$1500(this.this$0).tileOnScreen(localRSTile)) && (this.this$0.random(0, 10) > 7))
        GuildRanger.access$1700(this.this$0).walkTileOnScreen(GuildRanger.access$1600(this.this$0).getTileOnScreen(localRSTile));
      else {
        GuildRanger.access$1800(this.this$0).walkTo(localRSTile);
      }
      this.location = GuildRanger.access$1900(this.this$0).getDestination();
      this.this$0.sleep(this.this$0.random(1000, 1800));
    }
  }

  public void complete()
  {
    this.location = null;
  }

  public boolean isValid()
  {
    if (isTargetValid());
    return !this.destination.contains(new RSTile[] { this.this$0.getMyPlayer().getLocation() });
  }

  public String getDescription()
  {
    return "Walk To Area [" + this.description + "]";
  }
}